"""
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    created by siyi.chen on '20/11/2024'
    comment: cariabot自定义相关模型
"""
from fastapi import Body
from pydantic import Field
from sqlalchemy import func
from sqlalchemy.dialects.mysql import VARCHAR, DATETIME, TIMESTAMP, BOOLEAN, INTEGER
from laner.pydantic import BaseModel
from project import CustomModel
from project.core.base import Column, CustomList


class Cariabot(CustomModel):
    """ cariabot自定义模型
    """
    __tablename__ = "cariabot"
    id = Column(INTEGER(unsigned=True), primary_key=True, autoincrement=True)
    organization_code = Column(VARCHAR(20), nullable=False, server_default='', comment='机构编号')
    background_image = Column(VARCHAR(200), nullable=False, server_default='', comment='背景图')
    digital_human_id = Column(VARCHAR(20), nullable=False, server_default='', comment='数字人id')
    digital_human_image = Column(VARCHAR(200), nullable=False, server_default='', comment='数字人图片')
    awaken = Column(VARCHAR(20), nullable=False, server_default='', comment='唤醒词')
    voice_icon = Column(VARCHAR(200), nullable=False, server_default='', comment='语音图标')
    is_deleted = Column(BOOLEAN, nullable=False, server_default='0', comment='是否已删除', is_displayed=False)
    create_time = Column(DATETIME, nullable=False, server_default=func.now(), is_displayed=False)
    update_time = Column(TIMESTAMP, nullable=False, server_default=func.now(), onupdate=func.now(), is_displayed=False)


class CariabotColumn(CustomModel):
    """ cariabot侧边栏配置模型
    """
    __tablename__ = "cariabot_column"
    id = Column(INTEGER(unsigned=True), primary_key=True, autoincrement=True)
    cariabot_id = Column(INTEGER(unsigned=True), nullable=False, server_default='', comment='cariabot ID')
    name = Column(VARCHAR(20), nullable=False, server_default='', comment='名称')
    icon_checked = Column(VARCHAR(200), nullable=False, server_default='', comment='图标选中状态')
    icon_unchecked = Column(VARCHAR(200), nullable=False, server_default='', comment='图标未选中状态')
    column_type = Column(VARCHAR(20), nullable=False, server_default='', comment='栏目类型 flow(服务流程)/card(服务卡片)/evaluation(健康评估)/sleep(睡眠方案)/human(呼叫前台)/home(返回首页)/external(外部模块)/agent(智能助理)/shortcut(快捷入口)/voip(语音通话)/h5(h5页面)')
    tags = Column(CustomList(2000), nullable=False, server_default='', comment='标签')
    preamble = Column(VARCHAR(200), nullable=False, server_default='', comment='开场白')
    human_phone = Column(VARCHAR(20), nullable=False, server_default='', comment='前台电话')
    human_nickname = Column(VARCHAR(50), nullable=False, server_default='', comment='前台昵称')
    h5_url = Column(VARCHAR(200), nullable=False, server_default='', comment='h5页面地址')
    rank = Column(INTEGER, nullable=False, server_default='0', comment='顺序', is_displayed=False)
    is_deleted = Column(BOOLEAN, nullable=False, server_default='0', comment='是否已删除', is_displayed=False)
    create_time = Column(DATETIME, nullable=False, server_default=func.now(), is_displayed=False)
    update_time = Column(TIMESTAMP, nullable=False, server_default=func.now(), onupdate=func.now(), is_displayed=False)


class CariabotColumnService(CustomModel):
    """ 栏目服务内容表
    """
    __tablename__ = "cariabot_column_service"
    id = Column(INTEGER(unsigned=True), primary_key=True, autoincrement=True)
    column_id = Column(INTEGER(unsigned=True), nullable=False, server_default='0', comment='栏目id')
    code = Column(VARCHAR(30), nullable=False, server_default='', comment='编号')
    name = Column(VARCHAR(30), nullable=False, server_default='', comment='名称')
    image = Column(VARCHAR(200), nullable=False, server_default='', comment='图片')
    url = Column(VARCHAR(200), nullable=False, server_default='', comment='链接')
    preamble = Column(VARCHAR(200), nullable=False, server_default='', comment='数字人对白')
    rank = Column(INTEGER, nullable=False, server_default='0', comment='排序字段')
    is_deleted = Column(BOOLEAN, nullable=False, server_default='0', comment='是否已删除', is_displayed=False)
    create_time = Column(DATETIME, nullable=False, server_default=func.now(), is_displayed=False)
    update_time = Column(TIMESTAMP, nullable=False, server_default=func.now(), onupdate=func.now(), is_displayed=False)


class CariabotColumnServiceView(BaseModel):
    """ Cariabot侧边栏目服务视图
    """
    code: str = Field('', title='编号')
    name: str = Field('', title='名称')
    image: str = Field('', title='图片')
    url: str = Field('', title='链接')
    preamble: str = Field('', title='数字人对白')


class CariabotColumnView(BaseModel):
    """ Cariabot侧边栏目视图
    """
    id: int = Field('', title='栏目id')
    name: str = Field('', title='栏目名称')
    icon_checked: str = Field('', title='图标选中状态')
    icon_unchecked: str = Field('', title='图标未选中状态')
    column_type: str = Field('', title='栏目类型')
    service_list: list[CariabotColumnServiceView] = Field([], title='服务列表')
    tags: list[str] = Field([], title='标签列表')
    preamble: str = Field('', title='栏目开场白')
    human_phone: str = Field('', title='前台号码')
    human_nickname: str = Field('', title='前台昵称')
    h5_url: str = Field('', title='h5地址')


class CariabotView(BaseModel):
    """ cariabot自定义视图
    """
    background_image: str = Field('', title='背景图')
    digital_human_id: str = Field('', title='数字人id')
    digital_human_image: str = Field('', title='数字人图片')
    awaken: str = Field('', title='唤醒词')
    voice_icon: str = Field('', title='语音图标')
    columns: list[CariabotColumnView] = Body([], title='侧边栏目')


class CariabotIcon(CustomModel):
    """ 图标
    """
    __tablename__ = "cariabot_icon"
    id = Column(INTEGER(unsigned=True), primary_key=True, autoincrement=True)
    name = Column(VARCHAR(30), nullable=False, server_default='', comment='名称')
    type = Column(VARCHAR(30), nullable=False, server_default='', comment='图标类型 flow(服务流程)/sidebar(侧边栏)')
    size = Column(VARCHAR(10), nullable=False, server_default='', comment='尺寸: big(大)/middle(中)/small(小)')
    oss_path = Column(VARCHAR(200), nullable=False, server_default='', comment='oss地址')
    checked = Column(VARCHAR(200), nullable=False, server_default='', comment='选中状态')
    unchecked = Column(VARCHAR(200), nullable=False, server_default='', comment='未选中状态')
    remark = Column(VARCHAR(200), nullable=False, server_default='', comment='备注')
    create_time = Column(DATETIME, nullable=False, server_default=func.now(), is_displayed=False)
    update_time = Column(TIMESTAMP, nullable=False, server_default=func.now(), onupdate=func.now(), is_displayed=False)


class Invoice(CustomModel):
    """ 发票表
    """
    __tablename__ = "invoice"
    id = Column(INTEGER(unsigned=True), primary_key=True, autoincrement=True)
    flow_record_id = Column(INTEGER(unsigned=True), nullable=False, server_default='0', comment='服务记录id')
    room_number = Column(VARCHAR(20), nullable=False, server_default='', comment='房间号')
    invoice_type = Column(VARCHAR(20), nullable=False, server_default='', comment='发票类型 electronic(电子发票)/paper(纸质发票)')
    title_type = Column(VARCHAR(20), nullable=False, server_default='', comment='抬头类型 enterprise(企业单位)/individual(个人/非企业单位)')
    invoice_title = Column(VARCHAR(100), nullable=False, server_default='', comment='发票抬头')
    tax_number = Column(VARCHAR(50), nullable=False, server_default='', comment='税号')
    email = Column(VARCHAR(50), nullable=False, server_default='', comment='邮箱')
    bank_name = Column(VARCHAR(100), nullable=False, server_default='', comment='开户银行')
    bank_account = Column(VARCHAR(50), nullable=False, server_default='', comment='银行账号')
    company_address = Column(VARCHAR(100), nullable=False, server_default='', comment='公司地址')
    company_phone = Column(VARCHAR(50), nullable=False, server_default='', comment='公司电话')
    create_time = Column(DATETIME, nullable=False, server_default=func.now(), is_displayed=False)
    update_time = Column(TIMESTAMP, nullable=False, server_default=func.now(), onupdate=func.now(), is_displayed=False)


class Organization(CustomModel):
    """ 机构表
    """
    __tablename__ = "organization"
    code = Column(VARCHAR(30), primary_key=True, comment='机构编号')
    agent_profile = Column(VARCHAR(200), nullable=False, server_default='', comment='agent配置')
    user_role = Column(VARCHAR(30), nullable=False, server_default='', comment='agent用户角色')
    card_token = Column(VARCHAR(500), nullable=False, server_default='', comment='幻境服务卡片token(冗余)')
    sleep_agent_message = Column(VARCHAR(500), nullable=False, server_default='', comment='睡眠agent话术(冗余)')
    create_time = Column(DATETIME, nullable=False, server_default=func.now(), is_displayed=False)
    update_time = Column(TIMESTAMP, nullable=False, server_default=func.now(), onupdate=func.now(), is_displayed=False)


class DeviceJpush(CustomModel):
    """ 设备极光推送注册表
    """
    __tablename__ = "device_jpush"
    code = Column(VARCHAR(30), primary_key=True, comment='设备id')
    registration_id = Column(VARCHAR(30), nullable=False, server_default='', comment='极光上报id')
    organization_code = Column(VARCHAR(30), nullable=False, server_default='', comment='机构编号')
    create_time = Column(DATETIME, nullable=False, server_default=func.now(), is_displayed=False)
    update_time = Column(TIMESTAMP, nullable=False, server_default=func.now(), onupdate=func.now(), is_displayed=False)


class Activation(CustomModel):
    """ 激活码表
    """
    __tablename__ = "activation"
    code = Column(VARCHAR(30), primary_key=True, comment='激活码')
    code_type = Column(VARCHAR(30), nullable=False, server_default='', comment='码类型 healthy_photo(健康拍)')
    is_invalid = Column(BOOLEAN, nullable=False, server_default='0', comment='是否有无效 0: 有效 1: 无效')
    create_time = Column(DATETIME, nullable=False, server_default=func.now(), is_displayed=False)
    update_time = Column(TIMESTAMP, nullable=False, server_default=func.now(), onupdate=func.now(), is_displayed=False)


if __name__ == '__main__':
    pass
